package com.apop.common.controller;

import com.apop.common.mapper.OneMapper;
import com.apop.common.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Jiayi Zheng
 * @version V1.0
 * @ClassName UniController
 * @date 2021/11/10 15:35
 * @Description: 数据请求统一路由
 */
@RestController
@RequestMapping("/api")
@Slf4j
public class OneController {

    @Autowired
    private OneMapper oneMapper;

    @Autowired
    Environment env;

    @GetMapping
    public Result test() {
        return Result.success("v2.1");
    }

    /**
     * 清除全部缓存
     *
     * @param response
     * @return
     */
    @PostMapping("/clearAllCache")
    @CacheEvict(value = "ehcache", allEntries = true)
    public Result clearAllCache(HttpServletResponse response) {
        return Result.success("操作成功");
    }

}

